function pageSize() {
	if(!isMobile()){
		window.onresize = resize;
	}
	resize();
}

function resize()
{
	var size = {height : 0, width : 0 };

	if (document.documentElement && document.documentElement.scrollHeight) {
		size.width = document.documentElement.scrollWidth;
		size.height = document.documentElement.scrollHeight;
	}
	else {
		if (document.body) // other Explorers
		{
			size.width = document.body.scrollWidth;
			size.height = document.body.scrollHeight;
		}
	}
	
	if(size.width<1225)		
	{	
		document.getElementById("contenitoreMenu").appendChild(document.getElementById("login"));
		document.getElementById("contentHome").style.marginRight="1%";
		if(!isMobile())
			document.getElementById("contentHome").style.width="65%";
		document.getElementById("contentHome").style.float="right";
	}
	else {
		document.getElementById("contenitoreTutto").appendChild(document.getElementById("login"));
		document.getElementById("contentHome").style.marginRight="3.5%";
		document.getElementById("contentHome").style.width="50%";
		document.getElementById("contentHome").style.float="left";
//		if(document.getElementById('image')) 
//		{
//		imageVisible("image");
//		normalMarginContenitore("contenitore");
//		}
	}
	
	/* toglie le immagini sotto una certa dimensione */
	if(size.width<910) 
	{
		imageHidden("image");
		smallMarginContenitore("contenitore");
	}
	else {
		imageVisible("image");
		normalMarginContenitore("contenitore");
	}
	
	return size;
}

//---- VISUALIZZA E NASCONDE LE IMMAGINI DELLE MATERIE --- //
var allPageTags = new Array(); 


function imageHidden(theClass) {
	var allPageTags=document.getElementsByTagName("*");
	for (i=0; i<allPageTags.length; i++) {
		if (allPageTags[i].className==theClass) {			
			allPageTags[i].style.height="0";
			allPageTags[i].style.width="0";
			allPageTags[i].style.position="absolute";
			allPageTags[i].style.overflow="hidden";	
		}
	}
}

function imageVisible(theClass) {
	var allPageTags=document.getElementsByTagName("*");
	for (i=0; i<allPageTags.length; i++) {
		if (allPageTags[i].className==theClass) {
			allPageTags[i].style.height="80px";
			allPageTags[i].style.width="100px";
			allPageTags[i].style.overflow="visible";
		}
	}
}

function smallMarginContenitore(theClass) {
	var allPageTags=document.getElementsByTagName("*");
	for (i=0; i<allPageTags.length; i++) {
		if (allPageTags[i].className==theClass) {
			allPageTags[i].style.marginLeft="5px";
		}
	}
}

function normalMarginContenitore(theClass) {
	var allPageTags=document.getElementsByTagName("*");
	for (i=0; i<allPageTags.length; i++) {
		if (allPageTags[i].className==theClass) {
			allPageTags[i].style.marginLeft="130px";
		}
	}
}


function checkUserAgent(fromArticle){
	if(navigator.userAgent.indexOf("Windows NT") != -1) {
		return;
	}
	if(isMobile()) {
		if (fromArticle =='yes') {
			document.getElementsByTagName('link')[0].setAttribute("href", "../../style/mobile.css");
		} else {
			document.getElementsByTagName('link')[0].setAttribute("href", "../style/mobile.css");
		}
		document.getElementById("contenitoreMenu").appendChild(document.getElementById("login"));
	}
}

function isMobile() {
if(navigator.userAgent.indexOf("Windows NT") != -1) {
		return false;
	}
	var mobileString = new Array(
			"iPhone","Android","MIDP","Opera Mobi",  
			"Opera Mini","BlackBerry","HP iPAQ","IEMobile",  
			"MSIEMobile","Windows Phone","HTC","LG",  
			"MOT","Nokia","Symbian","Fennec",  
			"Maemo","Tear","Midori","armv",  
			"Windows CE","WindowsCE","Smartphone","240x320",  
			"176x220","320x320","160x160","webOS",  
			"Palm","Sagem","Samsung","SGH",  
			"SIE","SonyEricsson","MMP","UCWEB");

	for(var i=0; i<36; i++){
		if(navigator.userAgent.indexOf(mobileString[i]) != -1) {
			return true;
		}
	}
	return false;
}
